const express = require("express");
const router = express.Router();

//引入mock模块
const Mock = require("mockjs");

//测试接口
router.get("/", (req, res) => {
  res.send("测试成功");
});
// 获取mock数据
router.get("/systemMock", (req, res) => {
  let data = Mock.mock({
    status: 200,
    chassis: {
      "pattern|1": ["自主导航", "定点控制", "遥控", "巡航"],
      "speed|1-30.2": 1,
      "angle|1-10.2": 1,
      "status|1": ["系统正常", "系统故障", "系统维修"],
      "errInfo|0-10": 1,
    },
    battery: {
      "voltage|1-20": 1,
      "current|1-10": 1,
      "electricity|1-100": 1,
      "temperature|15-50": 1,
    },
    sensor:{
      "camera|1":["true","false"],
      "imu|1":["true","false"],
      "lidar|1":["true","false"],
    },
    mileage:{
      "totalMileage|1-10.2":1,
      "currentMileage|1-10.2":1,
    },
    disk:{
      "totalDisk|200-300":1,
      "freeDisk|1-200":1,
    }
  });
  res.send(data);
});

router.get("/homeworkMock", (req, res) => {
  let data = Mock.mock({
    "progressPercent|1-100": 1,
    "status|1": ["空闲中","作业中","任务暂停","已完成"],
    "positionStatus|1":["定位准确","定位偏差较大","定位失败"],
    "netDelay|10-100":1,
    position:{
      "xAxis|-1-1.2":1,
      "yAxis|-1-1.2":1,
      "degree|0-3.2":1,
    },
  });
  res.send(data);
});

module.exports = router;
